home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / cvs-1_3.lha / cvs-1.3 / src / create_adm.c < prev    next >
C/C++ Source or Header  |  1992-03-31  |  2KB  |  101 lines

  1. /*
  2.  * Copyright (c) 1992, Brian Berliner and Jeff Polk
  3.  * Copyright (c) 1989-1992, Brian Berliner
  4.  * 
  5.  * You may distribute under the terms of the GNU General Public License as
  6.  * specified in the README file that comes with the CVS 1.3 kit.
  7.  * 
  8.  * Create Administration.
  9.  * 
  10.  * Creates a CVS administration directory based on the argument repository; the
  11.  * "Entries" file is prefilled from the "initrecord" argument.
  12.  */
  13.  
  14. #include "cvs.h"
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "@(#)create_adm.c 1.24 92/03/31";
  18. #endif
  19.  
  20. void
  21. Create_Admin (dir, repository, tag, date)
  22.     char *dir;
  23.     char *repository;
  24.     char *tag;
  25.     char *date;
  26. {
  27.     FILE *fout;
  28.     char *cp;
  29.     char tmp[PATH_MAX];
  30.  
  31.     if (noexec)
  32.     return;
  33.  
  34.     if (!isdir (repository))
  35.     error (1, 0, "there is no repository %s", repository);
  36.  
  37.     if (dir != NULL)
  38.     (void) sprintf (tmp, "%s/%s", dir, CVSADM);
  39.     else
  40.     (void) strcpy (tmp, CVSADM);
  41.  
  42.     if (isfile (tmp))
  43.     error (1, 0, "there is a version here already");
  44.     else
  45.     {
  46.     if (dir != NULL)
  47.         (void) sprintf (tmp, "%s/%s", dir, OCVSADM);
  48.     else
  49.         (void) strcpy (tmp, OCVSADM);
  50.  
  51.     if (isfile (tmp))
  52.         error (1, 0, "there is a version here already");
  53.     }
  54.  
  55.     if (dir != NULL)
  56.     (void) sprintf (tmp, "%s/%s", dir, CVSADM);
  57.     else
  58.     (void) strcpy (tmp, CVSADM);
  59.     make_directory (tmp);
  60.  
  61.     if (dir != NULL)
  62.     (void) sprintf (tmp, "%s/%s", dir, CVSADM_REP);
  63.     else
  64.     (void) strcpy (tmp, CVSADM_REP);
  65.     fout = open_file (tmp, "w+");
  66.     cp = repository;
  67.     strip_path (cp);
  68.  
  69. #ifdef RELATIVE_REPOS
  70.     /*
  71.      * If the Repository file is to hold a relative path, try to strip off
  72.      * the leading CVSroot argument.
  73.      */
  74.     if (CVSroot != NULL)
  75.     {
  76.     char path[PATH_MAX];
  77.  
  78.     (void) sprintf (path, "%s/", CVSroot);
  79.     if (strncmp (repository, path, strlen (path)) == 0)
  80.         cp = repository + strlen (path);
  81.     }
  82. #endif
  83.  
  84.     if (fprintf (fout, "%s\n", cp) == EOF)
  85.     error (1, errno, "write to %s failed", tmp);
  86.     if (fclose (fout) == EOF)
  87.     error (1, errno, "cannot close %s", tmp);
  88.  
  89.     /* now, do the Entries file */
  90.     if (dir != NULL)
  91.     (void) sprintf (tmp, "%s/%s", dir, CVSADM_ENT);
  92.     else
  93.     (void) strcpy (tmp, CVSADM_ENT);
  94.     fout = open_file (tmp, "w+");
  95.     if (fclose (fout) == EOF)
  96.     error (1, errno, "cannot close %s", tmp);
  97.  
  98.     /* Create a new CVS/Tag file */
  99.     WriteTag (dir, tag, date);
  100. }
  101.